/*=============================================================================*
 *         Copyright(c) 2009-2010, Siemens PLM Software Inc.
 *                          ALL RIGHTS RESERVED
 *
 *  PURPOSE  : entry-in c file for tc customization handler and user service
 *  
 *  HISTORY  :
 *		DATE			VERSION			AUTHOR			NOTE
 *		2013-11-25		V1.0			liule			Created.
 *		2016-08-05		V2.0			liule			CM Handler Created.
 *    
 *============================================================================*/
#pragma warning(once:4996)
#pragma warning(once:4819)

#include "fjc_handler_defines.hxx"
#include "fjc_handler_utils.hxx"

#include "FJC_check_dataset.cxx"

#include "Ng4_CheckTargetsAlreadyInWorkflow.cxx"
#include "Ng4_RH_ValidateStatus.cxx"
#include "Ng4_InitiateAwardWorkflow.cxx"
#include "Ng4_CheckAwardBOMStatusValue.cxx"
#include "Ng4_CheckMasterProgramIsCheckOut.cxx"
#include "Ng4_CheckDeleteMasterProgram.cxx"
#include "Ng4_CheckDocAccess.cxx"
#include "Ng4_CheckStatusOnDatasets.cxx"
#include "Ng4_CheckPartRevInCO.cxx"
#include "Ng4_Notify.cxx"
#include "Ng4_ValidateParticipant.cxx"
#include "Ng4_Readiness_Check.cxx"
#include "Ng4_Perform_IA_Process.cxx"
#include "Ng4_applyReadyStatusForProg.cxx"
#include "Ng4_setAwardWorkflowStatus.cxx"
#include "Ng4_AwardWarningApproved.cxx"
#include "Ng4_AwardWarningRejected.cxx"
#include "Ng4_ListAndCountPrograms.cxx"
#include "Ng4_PerformCRImpactAnalysis.cxx"
#include "Ng4_ValidateSchedule.cxx"
#include "Ng4_Move_Attachment.cxx"
#include "Ng4_AddValidDesignToTarget.cxx"
#include "Ng4_Status_Related_Objects.cxx"
#include "Ng4_Validate_COPartRevision_Status.cxx"
#include "Ng4_ValidateSchedule_COVerification.cxx"
#include "Ng4ValidateSchedule_CORelease.cxx"
#include "Ng4_Assign_CO_Program_Manager.cxx"
#include "Ng4_RemoveDraftNRCDocumentState.cxx"
#include "Ng4_setDocumentCreator.cxx"
#include "Ng4_setDocumentState.cxx"
#include "Ng4_setDocumentOwnershipToCreator.cxx"
#include "Ng4_BatchStatus.cxx"
#include "Ng4_BatchDeleteStatus.cxx"
#include "Ng4_AssignSDTMember.cxx"
#include "Ng4_UpdateHasActiveDAOnProblemItems.cxx"
#include "Ng4_SelectAndCopyMajorRevFromAlterToSolItems.cxx"
#include "Ng4_PartDesignOwnershipSwitch.cxx"

extern DLLAPI int fjc_cust_register_custom_handlers(int *decision, va_list args)
{
	int rcode = ITK_ok;
	METHOD_id_t method;

	*decision = ALL_CUSTOMIZATIONS;

	printf("*************************************\n");
	printf("***Register Action handler in fjc cust START***\n");
	
	
	rcode = EPM_register_action_handler("FJC_check_dataset", "", FJC_check_dataset);
	if (rcode == ITK_ok)
	{
		printf( "FJC_check_dataset action handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - FJC_check_dataset action handler NOT registered!\n");
	}


	/*
	rcode = EPM_register_action_handler("F6_check_references", "", F6_check_references);
	if (rcode == ITK_ok)
	{
		printf( "F6_check_references action handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - F6_check_references action handler NOT registered!\n");
	}
	*/
	
	rcode = EPM_register_action_handler("Ng4MailNotify", "Mail Notify", Ng4_Notify);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_Notify action handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_Notify action handler NOT registered!\n");
	}
	
	rcode = EPM_register_action_handler("Ng4ValidateParticipant", "Validate participant", Ng4_ValidateParticipant);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_ValidateParticipant action handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_ValidateParticipant action handler NOT registered!\n");
	}
	
	rcode = EPM_register_action_handler("Ng4ReadinessCheck", "Readiness Check For All Change Objects", Ng4_Readiness_Check);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_Readiness_Check action handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_Readiness_Check action handler NOT registered!\n");
	}
	
	rcode = EPM_register_action_handler("Ng4PerformImpactAnalysis", "Perform Impact Analysis for DR", Ng4_Perform_IA_Process);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_Perform_IA_Process action handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_Perform_IA_Process action handler NOT registered!\n");
	}
	
	rcode = EPM_register_action_handler("Ng4-ApplyReadyStatusForProgram", "Apply Ready Status on Program Revision if all checks are passed", Ng4_applyReadyStatusForProg);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_applyReadyStatusForProg action handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_applyReadyStatusForProg action handler NOT registered!\n");
	}
	
	rcode = EPM_register_action_handler("Ng4-setAwardWorkflowStatus", "", Ng4_setAwardWorkflowStatus);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_setAwardWorkflowStatus action handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_setAwardWorkflowStatus action handler NOT registered!\n");
	}
	
	rcode = EPM_register_action_handler("Ng4-AwardWarningApproved", "", Ng4_AwardWarningApproved);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_AwardWarningApproved action handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_AwardWarningApproved action handler NOT registered!\n");
	}
	
	rcode = EPM_register_action_handler("Ng4-AwardWarningRejected", "", Ng4_AwardWarningRejected);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_AwardWarningRejected action handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_AwardWarningRejected action handler NOT registered!\n");
	}
	
	rcode = EPM_register_action_handler("Ng4ListAndCountPrograms", "", Ng4_ListAndCountPrograms);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_ListAndCountPrograms action handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_ListAndCountPrograms action handler NOT registered!\n");
	}
	
	rcode = EPM_register_action_handler("Ng4PerformCRImpactAnalysis", "", Ng4_PerformCRImpactAnalysis);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_PerformCRImpactAnalysis action handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_PerformCRImpactAnalysis action handler NOT registered!\n");
	}
	
	rcode = EPM_register_action_handler("Ng4ValidateSchedule", "", Ng4_ValidateSchedule);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_ValidateSchedule action handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_ValidateSchedule action handler NOT registered!\n");
	}
	
	rcode = EPM_register_action_handler("Ng4MoveAttachment", "", Ng4_Move_Attachment);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_Move_Attachment action handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_Move_Attachment action handler NOT registered!\n");
	}
	
	rcode = EPM_register_action_handler("Ng4AddValidDesignToTarget", "", Ng4_AddValidDesignToTarget);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_AddValidDesignToTarget action handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_AddValidDesignToTarget action handler NOT registered!\n");
	}
	
	rcode = EPM_register_action_handler("Ng4StatusRelatedObjects", "", Ng4_Status_Related_Objects);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_Status_Related_Objects action handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_Status_Related_Objects action handler NOT registered!\n");
	}
	
	rcode = EPM_register_action_handler("Ng4-Validate-COPartRevision-Status", "", Ng4_Validate_COPartRevision_Status);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_Validate_COPartRevision_Status action handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_Validate_COPartRevision_Status action handler NOT registered!\n");
	}
	
	rcode = EPM_register_action_handler("Ng4-ValidateSchedule-COVerification", "", Ng4_ValidateSchedule_COVerification);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_ValidateSchedule_COVerification action handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_ValidateSchedule_COVerification action handler NOT registered!\n");
	}
	
	rcode = EPM_register_action_handler("Ng4ValidateSchedule_CORelease", "", Ng4ValidateSchedule_CORelease);
	if (rcode == ITK_ok)
	{
		printf( "Ng4ValidateSchedule_CORelease action handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4ValidateSchedule_CORelease action handler NOT registered!\n");
	}
	
	rcode = EPM_register_action_handler("Ng4-Assign-CO-Program-Manager", "", Ng4_Assign_CO_Program_Manager);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_Assign_CO_Program_Manager action handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_Assign_CO_Program_Manager action handler NOT registered!\n");
	}
	
	rcode = EPM_register_action_handler("Ng4_RemoveDraftNRCDocumentState", "", Ng4_RemoveDraftNRCDocumentState);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_RemoveDraftNRCDocumentState action handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_RemoveDraftNRCDocumentState action handler NOT registered!\n");
	}
	
	rcode = EPM_register_action_handler("Ng4_setDocumentCreator", "", Ng4_setDocumentCreator);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_setDocumentCreator action handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_setDocumentCreator action handler NOT registered!\n");
	}
	
	rcode = EPM_register_action_handler("Ng4_setDocumentState", "", Ng4_setDocumentState);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_setDocumentState action handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_setDocumentState action handler NOT registered!\n");
	}
	
	rcode = EPM_register_action_handler("Ng4_setDocumentOwnershipToCreator", "", Ng4_setDocumentOwnershipToCreator);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_setDocumentOwnershipToCreator action handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_setDocumentOwnershipToCreator action handler NOT registered!\n");
	}
	
	rcode = EPM_register_action_handler("Ng4_BatchStatus", "", Ng4_BatchStatus);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_BatchStatus action handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_BatchStatus action handler NOT registered!\n");
	}
	
	rcode = EPM_register_action_handler("Ng4-Batch-Delete-Status-Handler", "", Ng4_BatchDeleteStatus);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_BatchDeleteStatus action handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_BatchDeleteStatus action handler NOT registered!\n");
	}
	
	rcode = EPM_register_action_handler("Ng4-Assign-SDTMember", "", Ng4_AssignSDTMember);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_AssignSDTMember action handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_AssignSDTMember action handler NOT registered!\n");
	}
	
	rcode = EPM_register_action_handler("Ng4-Update-DA-Indicator-On-PartRevision", "", Ng4_UpdateHasActiveDAOnProblemItems);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_UpdateHasActiveDAOnProblemItems action handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_UpdateHasActiveDAOnProblemItems action handler NOT registered!\n");
	}
	
	rcode = EPM_register_action_handler("Ng4SelectAndCopyMajorRevFromAlterToSolItems", "", Ng4_SelectAndCopyMajorRevFromAlterToSolItems);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_SelectAndCopyMajorRevFromAlterToSolItems action handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_SelectAndCopyMajorRevFromAlterToSolItems action handler NOT registered!\n");
	}
	
	rcode = EPM_register_action_handler("Ng4-Part-Design-Ownership-Switch", "", Ng4_PartDesignOwnershipSwitch);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_PartDesignOwnershipSwitch action handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_PartDesignOwnershipSwitch action handler NOT registered!\n");
	}
	
	printf("****Register Action handler in fjc cust END****\n");
	printf("*************************************\n");
	
	
	printf("=====================================\n");
	
	
	printf("*************************************\n");
	printf("***Register Rule handler in fjc cust START***\n");
	
	//Rule Handlers
	rcode = EPM_register_rule_handler("Ng4CheckTargetsAlreadyInWorkflow", "Checks InProcess Workflows", Ng4_CheckTargetsAlreadyInWorkflow);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_CheckTargetsAlreadyInWorkflow rule handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_CheckTargetsAlreadyInWorkflow rule handler NOT registered!\n");
	}
	
	rcode = EPM_register_rule_handler("Ng4-Validate-Status", "Validate status of the Objects", Ng4_RH_ValidateStatus);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_RH_ValidateStatus rule handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_RH_ValidateStatus rule handler NOT registered!\n");
	}
	
	rcode = EPM_register_rule_handler("Ng4-Initiate-AwardWorkflow", "Check for MPL Project to initiate Award Workflow", Ng4_InitiateAwardWorkflow);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_InitiateAwardWorkflow rule handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_InitiateAwardWorkflow rule handler NOT registered!\n");
	}
	
	rcode = EPM_register_rule_handler("Ng4-Check-AwardBOMStatus", "Check AwardBOMStatus Value", Ng4_CheckAwardBOMStatusValue);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_CheckAwardBOMStatusValue rule handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_CheckAwardBOMStatusValue rule handler NOT registered!\n");
	}
	
	rcode = EPM_register_rule_handler("Ng4-Check-MasterProgram-Is-Checked-Out", "Check Master Program Is Checked Out", Ng4_CheckMasterProgramIsCheckOut);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_CheckMasterProgramIsCheckOut rule handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_CheckMasterProgramIsCheckOut rule handler NOT registered!\n");
	}
	
	rcode = EPM_register_rule_handler("Ng4-Check-Delete-MasterProgram", "Check Delete Master Program", Ng4_CheckDeleteMasterProgram);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_CheckDeleteMasterProgram rule handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_CheckDeleteMasterProgram rule handler NOT registered!\n");
	}
	
	rcode = EPM_register_rule_handler("Ng4_CheckDocAccess", "Checks Access on Document Revision", Ng4_CheckDocAccess);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_CheckDocAccess rule handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_CheckDocAccess rule handler NOT registered!\n");
	}
	
	rcode = EPM_register_rule_handler("Ng4_CheckStatusOnDatasets", "Check Datasets Status associated to Document Revision", Ng4_CheckStatusOnDatasets);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_CheckStatusOnDatasets rule handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_CheckStatusOnDatasets rule handler NOT registered!\n");
	}
	
	rcode = EPM_register_rule_handler("Ng4-Check-PartRevIn-CO", "Check if Part revisions are present in single in-process CO", Ng4_CheckPartRevInCO);
	if (rcode == ITK_ok)
	{
		printf( "Ng4_CheckPartRevInCO rule handler successfully registered!\n");
	}
	else
	{
		printf( "WARNING - Ng4_CheckPartRevInCO rule handler NOT registered!\n");
	}
	
	printf("****Register Rule handler in fjc cust END****\n");
	printf("*************************************\n");
	
	return rcode;
}


/*=============================================================================*
 * FUNCTION: tc_cust_register_callbacks
 * PURPOSE : register user exit point
 * INPUT: 
 *     void
 *
 * RETURN: 
 *     int // ITK_ok:call successfully; not ITK_ok:error occur
 *============================================================================*/

extern DLLAPI int fjc_cust_register_callbacks()
{
	int rcode = ITK_ok;
	
	rcode = CUSTOM_register_exit("fjc_cust", "USER_gs_shell_init_module", (CUSTOM_EXIT_ftn_t)fjc_cust_register_custom_handlers);
	if(rcode != ITK_ok)
	{
		return rcode;
	}
	
	return(ITK_ok);
}